home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
eulisp
/
mpfeel.lha
/
MPFeel
/
Plurals
/
Modules
/
ring.em
< prev
next >
Wrap
Lisp/Scheme
|
1992-06-04
|
758b
|
38 lines
;
; Dining Philosophers
;
; File : ring
;
; Contents : ring
; make-ring
;
; Description : The philosophers sit around a circular table.
; To this end we create a ring shaped paralation.
;
; Author : SCM
;
; Change History :
;
; Date Name Comment
; 13:04:92 SCM Created
(defmodule ring (standard0 ppl plural) ()
(defconstant prev 0)
(defconstant next 1)
(defun make-ring (circ)
(let ((new (make-paralation circ))
(shape-vec (make-vector 2)))
((setter vector-ref) shape-vec next
(match new (elwise (new) (remainder (+ new (- circ 1)) circ))))
((setter vector-ref) shape-vec prev
(match new (elwise (new) (remainder (+ new 1) circ))))
((setter shape) new shape-vec)
new))
(export next prev make-ring)
)